package cn.jiyun.service.impl;

import cn.jiyun.dao.MemberDao;
import cn.jiyun.pojo.Member;
import cn.jiyun.serivce.LoginService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private MemberDao memberDao;

    @Override
    public Member isMember(String telephone) {
        Member member = memberDao.findByPhone(telephone);
        if(member==null){
//            如果不是会员则自动完成注册并进行预约
            member = new Member();
            member.setPhoneNumber(telephone);
            member.setRegTime(new Date());
            memberDao.add(member);
        }

        return member;
    }
}
